avg :: [Integer] -> Integer
avg xs = foldl1 (\a b -> a + b + a * b) xs

main = do
    n <- getLine
    l <- getLine
    let s = avg $ map read $ words l   
    print $ s `mod` 1000000007